﻿using Microsoft.AspNetCore.Http;
using NPOI.SS.Formula.Functions;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
using XW.Utils;

namespace XW.Core
{
	public static class IUpdateableExtent
	{
        public static IUpdateable<T> setColumnsUpdateUserAndTime<T>(this IUpdateable<T> u) where T : EntityBase, new()
        {
            u.SetColumns(item => item.UpdateTime == SqlFunc.GetDate());
            string? userId = SXHttpContext.Current.User.FindFirstValue(JwtTokenConst.JWT_USER_ID);// 用户id
            long id = CommonHelper.ToInt64(userId, 0);
            u.SetColumns(item => item.UpdateUserId == id);
            return u;
        }
    }
}
